TPaneSplit Component
Properties	Methods	Events

Registration

Unit:

Split

Description

The TPaneSplit component allows users to move the mouse over a bar between two scaleable regions, and drag it to change the size of the two panes on either side of the splitter.  A component of this type is used in many popular Windows programs, including the Windows 95 Explorer and the popular Free Agent newsreader.

However, the TPaneSplit component takes this concept one step farther.

When the split bar is clicked with the left button, it allows normal dragging, as all Splitter type components do.  But when the user (or designer) clicks on it with the right button, the splitter can transform into a Toolbar of sorts (as seen at the left).  The topmost button changes the orientation of the splitter from horizontal to vertical.  The next button switches the splitters panes.  Thus, in the example to the left, the File Listbox and Directory Listbox would be switched.  The last two buttons are maximize buttons for each pane.  This allows the user to zoom in on panes of interest.

These enhancements allow the designer to give the user an extremely dynamic interface from which to work.

TPaneSplit also contains all of the necessary routines to save and load all of its necessary properties from an INI file.  This allows you to add position and orientation saving and loading without any code.


TPaneSplit Properties

 Key Properties:

PaneStyle	SplitPercent	DrawToolRect
BorderTop	SplitDragStyle	ToolsRightClick
BorderLeft	Bevel	INIUseAppDir
BorderBottom	BevelStyle	INIFileName
BorderRight	SplitHorizCursor	INISection
SplitStyle	SplitVertCursor	INIKey
SplitWidth	ToolBarShowing	INIAutoSave
SplitPos	ToolColor	INIAutoLoad
DraggingSplitter

Inherited Properties:

Top	DragCursor	ParentShowHint
Left	DragMode	ShowHint
Height	Enabled	PopupMenu
Width	Font	Visible
Color	ParentFont
Align	ParentColor


TPaneSplit Methods

 Key Methods:

INISave

INILoad


TPaneSplit Events

 Key Events:

OnChange

Inherited Events:

OnClick

OnDblClick

OnStartDrag

OnDragDrop

OnDragOver

OnEndDrag

OnMouseDown

OnMouseMove

OnMouseUp


Registration:

The shareware version of this component is fully functional inside the Delphi environment.  However, attempts to run this component from a standalone executable will fail.  If you find this control useful and would like to use it in your applications you must order the registered version

For $15 (U.S.) you will receive the fully functional version of this component plus any additional updates and bug fixes for as long as I continue to support the product.  The component will be available for download in a password protected zip file from http:/www.ksu.edu/~mjn/components.html or, upon special request, can be sent to you by e-mail (UUEncoded).  The full source code is available for an additional $5.

To order by e-mail, run the registration program included with this distribution.  Or, you can register over the Word Wide Web, at the URL:  http:/www.kagi.com/authors/mjn.  Your registration will be processed in anywhere from a from a few hours, to a few days, depending upon the method of payment.

Any technical questions regarding this component should forwarded to the email address below.

Disclaimer:  I  claim NO responsibility for any damages or loss, direct or indirect, caused by use of this component.

Legal (please read):  You may freely distribute any application containing this component royalty free once you have registered.  However, you may not distribute the source for this component with your application.  Should you register this component, I will do my best to answer any questions you may have regarding the component, and will attempt to fix any bug reported.  But, keep in mind, producing shareware is not how I make a living.

Contact Info:

Michael Novak
1817 Hunting Ave, Apt. #3
Manhattan, KS  66502
mjn@ksu.ksu.edu

TPaneSplit, (c) 1996, Michael Novak


Split Unit

Components:

TPaneSplit

For your convenience, the interface section of the split unit is below.

unit Split;

interface

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

  ExtCtrls, Buttons, INIFiles;

const

  ToolWidth = 16;

type

  TPane = class(TCustomControl)

  private

    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;

  protected

    procedure ReadState(Reader: TReader); override;

  public

    constructor Create( AOwner:TComponent ); override;

  end;

  TPaneStyle = (psHorizontal, psVertical);

  TSplitStyle = (ssPercent, ssFixed1, ssFixed2);

  TSplitDragStyle = ( sdLines, sdSolid );

  TPaneSplit = class(TCustomControl)

  private

    (* the actual panes *)

    FP1, FP2        :TPane;

    (* pane orientation *)

    FPaneStyle    :TPaneStyle;

    FPaneSwitched :Boolean;

    (* border widths *)

    FBorderTop    :Byte;

    FBorderLeft   :Byte;

    FBorderBottom :Byte;

    FBorderRight  :Byte;

    (* splitter style *)

    FSplitStyle   :TSplitStyle;

    (* splitter width and positioning *)

    FSplitWidth     :Byte;

    FUserSplitWidth :Byte;

    FSplitPos       :Integer;

    FSplitPercent   :Integer;

    (* bevel style *)

    FBevelStyle     :TBevelStyle;

    FBevel          :Boolean;

    (* resize cursors *)

    FSplitHorizCursor :TCursor;

    FSplitVertCursor  :TCursor;

    (* tool bar *)

    FToolBarShowing   :Boolean;

    FToolColor        :TColor;

    FDrawToolRect     :Boolean;

    FToolsRightClick  :Boolean;

    (* misc needs *)

    FDraggingSplitter :Boolean;   (* r we dragging the splitter? *)

    CursorRect        :tRect;

    SplitRect         :tRect;

    FSplitDragStyle   :TSplitDragStyle;

    FDragPos          :Integer;   (* position we've drug the splitter to *)

    FDragOffset       :Integer;   (* offset from mouse position to bar start *)

    FLastDragPos      :Integer;   (* last position drag bar drawn in *)

    FOldWidth         :Integer;   (* needed to tell previous width before WM_Size is called *)

    FNCHitTest        :TPoint;    (* mouse position *)

    FPaneButtonDown   :Boolean;

    FSwitchButtonDown :Boolean;

    FMax1ButtonDown   :Boolean;

    FMax2ButtonDown   :Boolean;

    FRightDown        :Boolean;

    FOldSplitPos      :Integer;

    FMax1Return       :Boolean;

    FMax2Return       :Boolean;

    FINIUseAppDir     :Boolean;

    FINIFileName      :String;

    FINISect          :String;

    FINIKey           :String;

    FINIAutoSave      :Boolean;

    FINIAutoLoad      :Boolean;

    FOnChange         :TNotifyEvent;

    procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;

    procedure CMMouseLeave(var Message: TMessage ); message CM_MOUSELEAVE;

    procedure CMCursorChanged(var Message: TMessage); message CM_CURSORCHANGED;

    procedure WMSize(var Message: TWMSize); message WM_SIZE;

    procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;

    procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;

    procedure WMLButtomUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;

    procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;

    procedure WMRButtonUp(var Message: TWMRButtonDown); message WM_RBUTTONUP;

    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;

    procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;

  protected

    (* property setting *)

    procedure SetPaneStyle( value:TPaneStyle );

    procedure SetBorderTop( value:Byte );

    procedure SetBorderLeft( value:Byte );

    procedure SetBorderBottom( value:Byte );

    procedure SetBorderRight( value:Byte );

    procedure SetSplitStyle( value:TSplitStyle );

    procedure SetSplitWidth( value:Byte );

    procedure SetSplitPos( value:Integer );

    procedure SetSplitPercent( value:Integer );

    procedure SetBevelStyle( value:TBevelStyle );

    procedure SetBevel( value:Boolean );

    procedure SetToolBar( value:Boolean );

    procedure SetToolColor( value:TColor );

    procedure SetDrawToolRect( value:Boolean );

    (* saving and restoring *)

    procedure WriteState(Writer: TWriter); override;

    procedure ReadState(Reader: TReader); override;

    (* draw the drag bar *)

    procedure DrawDragBar( Pos:Integer );

    (* see if the cursor is over the split bar *)

    function OverSplitter:Boolean;

    (* get width and height non-respective to orientation *)

    function NWidth:Integer;

    function NHeight:Integer;

    function  OverMax2Button:Boolean;

    procedure DrawMax2Button( Raised:Boolean );

    function  OverMax1Button:Boolean;

    procedure DrawMax1Button( Raised:Boolean );

    function  OverSwitchButton:Boolean;

    procedure DrawSwitchButton( Raised:Boolean );

    function  OverPaneButton:Boolean;

    procedure DrawPaneButton( Raised:Boolean );

    procedure Paint; override;

    procedure RePosition; dynamic;

  public

    constructor Create( AOwner:TComponent ); override;

    destructor  Destroy; override;

    property    DraggingSplitter:Boolean read FDraggingSplitter;

    procedure   INISave;

    procedure   INILoad;

  published

    (* pane orientation *)

    property PaneStyle:TPaneStyle read FPaneStyle write SetPaneStyle default psHorizontal;

    (* border widths *)

    property BorderTop:Byte read FBorderTop write SetBorderTop default 2;

    property BorderLeft:Byte read FBorderLeft write SetBorderLeft default 2;

    property BorderBottom:Byte read FBorderBottom write SetBorderBottom default 2;

    property BorderRight:Byte read FBorderRight write SetBorderRight default 2;

    (* splitter width and positioning *)

    property SplitStyle:TSplitStyle read FSplitStyle write SetSplitStyle default ssPercent;

    property SplitWidth:Byte read FSplitWidth write SetSplitWidth default 2;

    property SplitPos:Integer read FSplitPos write SetSplitPos;

    property SplitPercent:Integer read FSplitPercent write SetSplitPercent default 50;

    property SplitDragStyle:TSplitDragStyle read FSplitDragStyle write FSplitDragStyle default sdLines;

    (* bevel style - raised, lowered *)

    property BevelStyle:TBevelStyle read FBevelStyle write SetBevelStyle default bsLowered;

    property Bevel:Boolean read FBevel write SetBevel default true;

    (* resize cursors *)

    property SplitHorizCursor:TCursor read FSplitHorizCursor write FSplitHorizCursor default crHSplit;

    property SplitVertCursor:TCursor read FSplitVertCursor write FSplitVertCursor default crVSplit;

    (* toolbar? *)

    property ToolBarShowing:Boolean read FToolBarShowing write SetToolBar default false;

    property ToolColor:TColor read FToolColor write SetToolColor default clBtnText;

    property DrawToolRect:Boolean read FDrawToolRect write SetDrawToolRect default true;

    property ToolsRightClick:Boolean read FToolsRightClick write FToolsRightClick default true;

    (* INI stuff *)

    property INIUseAppDir:Boolean read FINIUseAppDir write FINIUseAppDir;

    property INIFileName:String read FINIFileName write FINIFileName;

    property INISection:String read FINISect write FINISect;

    property INIKey:String read FINIKey write FINIKey;

    property INIAutoSave:Boolean read FINIAutoSave write FINIAutoSave;

    property INIAutoLoad:Boolean read FINIAutoLoad write FINIAutoLoad;

    property Top;

    property Left;

    property Height;

    property Width;

    property Color;

    property Align;

    property DragCursor;

    property DragMode;

    property Enabled;

    property Font;

    property ParentFont;

    property ParentColor;

    property ParentShowHint;

    property ShowHint;

    property PopupMenu;

    property Visible;

    property OnClick;

    property OnDblClick;

    property OnStartDrag;

    property OnDragDrop;

    property OnDragOver;

    property OnEndDrag;

    property OnMouseDown;

    property OnMouseMove;

    property OnMouseUp;

    property OnChange:TNotifyEvent read FOnChange write FOnChange;

  end;

procedure Register;

implementation


PaneStyle Property

Applies to:

TPaneSplit component

Declaration

property PaneStyle:TPaneStyle;

TPaneStyle = (psVertical, psHorizontal);

Description:

This property determines whether the splitter is shown Horizontally, or Vertically.  The user, provided ToolsRightClick is set to True, can use the pane button on the toolbar to change this orientation at run time or design time.


BorderTop Property

Applies to:

TPaneSplit component

Declaration

property BorderTop:Byte

Description:

This property determines how many pixels are allowed on the top of the control before the first Pane is drawn.

See Also:

BorderLeft

BorderBottom

BorderRight


BorderLeft Property

Applies to:

TPaneSplit component

Declaration

property BorderLeft:Byte

Description:

This property determines how many pixels are allowed on the left side of the control before the first Pane is drawn.

See Also:

BorderTop

BorderBottom

BorderRight


BorderBottom Property

Applies to:

TPaneSplit component

Declaration

property BorderBottom:Byte

Description:

This property determines how many pixels are allowed on the bottom of the control.

See Also:

BorderTop

BorderLeft

BorderRight


BorderRight Property

Applies to:

TPaneSplit component

Declaration

property BorderRight:Byte;

Description:

This property determines how many pixels are allowed on the right side of the control.

See Also:

BorderTop

BorderLeft

BorderBottom


SplitStyle Property

Applies to:

TPaneSplit component

Declaration

property SplitStyle:TSplitStyle;

TSplitStyle = (ssPercent, ssFixed1, ssFixed2);

Description:

This property determines how the controls handles resizing.  If the SplitStyle is ssPercent, then when the user resizes the control, the SplitBar is kept at a relative percent to the original location.  In other words, if SplitPos was 50, and the width was 100, if the control was resized so its with was 50, the SplitPos would then become 25.

The ssFixed1 and ssFiexed2 styles attempt to keep either Pane 1, or Pane 2 the same width.  In the example above, if ssFixed1 was set, the SplitPos would become 50.  If ssFixed2 was set, the SplitPos would be 0.

See Also:

SplitWidth

SplitPos

SplitPercent

SplitDragStyle


SplitWidth Property

Applies to:

TPaneSplit component

Declaration

property SplitWidth:Byte

Description:

This property determines how wide the bar separating the panes is.  The property defaults to 2.  When ToolBarShowingisset, this property will be 16.  However, the original value is also saved.  So, if you set SplitWidth to 4, and then set ToolBarShowing to True the property changes to 16.  But, when you set ToolBarShowing back to False, the property will revert back to 4.

Also, if you change the SplitWidth while the tool bar is showing, it will automatically hide the tool bar.

See Also:

SplitStyle

SplitPos

SplitPercent

SplitDragStyle


SplitPos Property

Applies to:

TPaneSplit component

Declaration

property SplitPos:Integer;

Description:

This property determines the position of the SplitBar within the control.  This number actually represents the position of the first pixel of the bar (left or top).  You need not worry about bounds when setting this property.  The control makes sure that SplitPos is always valid, and moves the splitter as is appropriate.

If SplitStyle is set to ssPercent, then the component automatically updates the SplitPos based on the size of the window.  The user can also change the SplitPos by dragging the splitter.

See Also:

SplitStyle

SplitWidth

SplitPercent

SplitDragStyle


SplitPercent Property

Applies to:

TPaneSplit component

Declaration

property SplitPercent:Integer;

Description:

This determines the percentage to keep when updating resizes of the split bar.  This value should be set within the range of 0 and 100.

Note:  This property is irrelevant if SplitStyle is not set to ssPercent.

See Also:

SplitStyle

SplitWidth

SplitPos

SplitDragStyle


SplitDragStyle Property

Applies to:

TPaneSplit component

Declaration

property SplitDragStyle:TSplitDragStyle;

TSplitDragStyle = ( sdLines, sdSolid );

Description:

This property determines what type of indication is drawn when the user drags the split bar.  If sdSolid is set, then a rectangle the same size of the splitter is drawn.  If sdLines is set, two lines, one on each side of the splitter, are drawn.

See Also:

SplitStyle

SplitWidth

SplitPos

SplitPercent


Bevel Property

Applies to:

TPaneSplit component

Declaration

property Bevel:Boolean;

Description:

This property determines whether or not bevels are drawn around the edges of the panes.  The BevelStyle property determines how these bevels appear.


BevelStyle Property

Applies to:

TPaneSplit component

Declaration

property BevelStyle:TBevelStyle;

Description:

This property determines how the bevels drawn around the panes appear.  The Bevel property determines whether or not these bevels are drawn.


SplitHorizCursor Property

Applies to:

TPaneSplit component

Declaration

property SplitHorizCursor:TCursor;

Description:

This property sets which cursor the component uses when the user can re-size the split bar horizontally.


SplitVertCursor Property

Applies to:

TPaneSplit component

Declaration

property SplitVertCursor:TCursor;

Description:

This property sets which cursor the component uses when the user can re-size the split bar vertically.


ToolBarShowing Property

Applies to:

TPaneSplit component

Declaration

property ToolBarShowing:Boolean;

Description:

When set, this property shows or hides the ToolBar.  The ToolBar allows users expanded control over the orientation of the split bar.  The ToolsRightClick property determines whether or not the user can bring up the tool bar.

SeeAlso:

ToolColor

DrawToolRect

ToolsRightClick


ToolColor Property

Applies to:

TPaneSplit component

Declaration

property ToolColor:TColor;

Description:

This property sets the color that is used to draw the face of the buttons and the rectangle between the buttons on the tool bar.

SeeAlso:

ToolBarShowing

DrawToolRect

ToolsRightClick


DrawToolRect Property

Applies to:

TPaneSplit component

Declaration

property DrawToolRect:Boolean;

Description:

When this property is true, and ToolBarShowing is true, a rectangle indicating re-size area is drawn between the buttons on the left and right sides.

SeeAlso:

ToolBarShowing

ToolColor

ToolsRightClick


ToolsRightClick Property

Applies to:

TPaneSplit component

Declaration

property ToolsRightClick:Boolean;

Description:

When this property is set to true, the user can right-click on the SplitBar of the component, and bring up (and down) the ToolBar.  Essentially, when the user right-clicks, the ToolBarShowing property is changed.

SeeAlso:

ToolBarShowing

ToolColor

DrawToolRect


INIUseAppDir Property

Applies to:

TPaneSplit component

Declaration

property INIUseAppDir::Boolean;

Description:

When this property is set to true, the component prepends the current applications path to the INIFileName before attempting to open and close it.  If this is the desired behavior, then make certain the INIFileName is only a filename, and not a complete path.  If INIFileName is only a filename (with no path information) and INIUseAppDir is set to false then the INI file is written/read from the current directory.

See Also:

INIFileName

INISection

INIKey

INIAutoSave

INIAutoLoad


INIFileName Property

Applies to:

TPaneSplit component

Declaration

property INIFileName:String;

Description:

This property sets the name of the INI file that the component uses when reading or writing its positioning information from a file.  Use the INIUseAppDir property to make sure the file is written to your applications directory.

See Also:

INIUseAppDir

INISection

INIKey

INIAutoSave

INIAutoLoad


INISection Property

Applies to:

TPaneSplit component

Declaration

property INISection:String;

Description:

This property determines which section of the INI file specified by INIFileName is read from and written to.  You can write multiple configurations to the same section by changing the INIKey property.

See Also:

INIUseAppDir

INIFileName

INIKey

INIAutoSave

INIAutoLoad


INIKey Property

Applies to:

TPaneSplit component

Declaration

property INIKey:String;

Description:

This property is a key-word that is pre-pended to all INI variables to make them unique.  In this way, you can write multiple PaneSplit components to the same section in an INI file by simply changing the INIKey.  This will prevent your INI file from becoming too cluttered with configuration sections.

See Also:

INIUseAppDir

INIFileName

INISection

INIAutoSave

INIAutoLoad


INIAutoSave Property

Applies to:

TPaneSplit component

Declaration

property INIAutoSave:Boolean;

Description:

When this property is set to true, the component writes all necessary properties to restore its orientation and positioning to the INIFileName before it is destroyed.

See Also:

INIUseAppDir

INIFileName

INISection

INIKey

INIAutoLoad


INIAutoLoad Property

Applies to:

TPaneSplit component

Declaration

property INIAutoLoad:Boolean;

Description:

This property determines if the component will attempt to read all necessary properties to restore its orientation and positioning from the INIFileName before the component becomes visible.  The INIAutoSave property determines whether or not these properties are written to the file before the component is destroyed.

See Also:

INIUseAppDir

INIFileName

INISection

INIKey

INIAutoSave


DraggingSplitter Property

Applies to:

TPaneSplit component

Declaration

property DraggingSplitter:Boolean;

Description:

This property returns whether or not the user is currently dragging the splitter.

Note:  Run-Time Only and Read Only


INISave Method

Applies to:

TPaneSplit component

Declaration

procedure INISave;

Description:

This methods saves all the necessary orientation and positioning information to an INI file.

See Also:

INIUseAppDir

INIFileName

INISection

INIKey

INIAutoSave

INIAutoLoad


INILoad Method

Applies to:

TPaneSplit component

Declaration

procedure INILoad;

Description:

This method loads all necessary orientation and positioning information from an INI file.

See Also:

INIUseAppDir

INIFileName

INISection

INIKey

INIAutoSave

INIAutoLoad


OnChange Event

Applies to:

TPaneSplit component

Declaration

property OnChange:TNotifyEvent;

Description:

This event is called whenever the Splitters position or orientation changes.